﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace Model
{
    [ObjectEvent]
    public class DBComponentEvent : ObjectEvent<DBComponent>, IAwake<string>
    {
        public void Awake(string server)
        {
            Get().Awake(server);
        }
    }


    /// <summary>
    /// 数据库组件
    /// </summary>
    public class DBComponent : Component
    {
        private string dbServer = null;

        // 
        public void Awake(string dbServer)
        {
            this.dbServer = dbServer;
            //Log.Info("Conn:" + connStr);
            //dbServer = new DBContext(connStr);
          //  db.user.Add(new DB.User { Age = 10, Name = "李白" });

           // int i = db.SaveChanges();

           // var result = from s in db.user where s.Age == 10 select s;

           // Log.Info("保存：" + i);
        }

        /// <summary>
        /// 获取一个数据库上下文
        /// </summary>
        public DBContext DBContext
        {
            get
            {
                return new DBContext(dbServer);
            }
        }
    }
}